#include<iostream>
#include<cstring>
using namespace std;
string s;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		cin >> s;
		int ans = n;
		//cout << "n/2====" << n / 2 << endl;
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[n - 1 - i]) ans -= 2;
			else break;
		}
		cout << ans << endl;
	}
	return 0;
}